package cn.restcloud.example.controller;

import org.bson.Document;
import cn.restcloud.framework.core.annotation.bean.*;
import cn.restcloud.framework.core.annotation.rest.MethodType;
import cn.restcloud.framework.core.annotation.rest.RestConfig;
import cn.restcloud.framework.core.context.ServerContext;
import cn.restcloud.framework.view.base.DocAndView;
import cn.restcloud.framework.view.util.ViewUtil;

@BeanConfig(appId = "example",beanId = "ServerInfoRest",beanName = "获取服务器信息",beanType = BeanType.CONTROLLER)
@RestConfig(url = "/rest/example/server")
public class ServerInfoRest {

		@RestConfig(configName = "获取服务器IP及端口信息",method = MethodType.GET,url = "/info")
		public DocAndView getServerfo() throws Exception{
			Document doc=new Document();
			doc.put("serverId",ServerContext.getCurrentServerId());
			doc.put("port",ServerContext.getCurrentServerPort());
			doc.put("ip",ServerContext.getCurrentServerIP());
			doc.put("serviceName",ServerContext.getCurrentServiceName());
			doc.put("baseUrl",ServerContext.getCurrentServerHost());
			return ViewUtil.getJsonView(doc);
		}
		
	
}
